package com.ruoyi.admission.controller;

import com.ruoyi.admission.domain.AdmissionStudent;
import com.ruoyi.admission.service.IAdmissionStudentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/testController")
@Api(value = "测试控制器",tags = "测试控制器")
public class TestController extends BaseController {


    @Autowired
    private IAdmissionStudentService admissionStudentService;

    @GetMapping("/list")
    @ApiOperation(value = "list",notes = "list",tags = "list")
    public TableDataInfo list( ) {
        List<AdmissionStudent> list = admissionStudentService.list();
        return getDataTable(list);
    }

    @DeleteMapping("/deleteById")
    @ApiOperation(value = "deleteById",notes = "deleteById",tags = "deleteById")
    public AjaxResult deleteById(@RequestParam(value = "id")Integer id) {
        admissionStudentService.removeById(id);
        return success();
    }


    @PostMapping("add")
    @ApiOperation(value = "add",notes = "add",tags = "add")
    public AjaxResult add(@RequestBody AdmissionStudent admissionStudent) {
        admissionStudentService.save(admissionStudent);
        return success();
    }


    @PutMapping("/update")
    @ApiOperation(value = "update",notes = "update",tags = "update")
    public AjaxResult update(@RequestBody AdmissionStudent admissionStudent) {
        admissionStudentService.updateById(admissionStudent);
        return success();
    }


}
